package com.lanqiao.dao.impl;

import com.lanqiao.dao.BookDao;
import com.lanqiao.entity.BookInfo;
import com.lanqiao.entity.BookPicInfo;
import com.lanqiao.util.ORMUtil;

import java.util.List;

public class BookDaoImpl implements BookDao {
    /**
     * 插入图书
     * 返回的是添加图书的自增长值
     */
    @Override
    public int insertBook(BookInfo bookInfo) {
        String sql = "insert into tb_book(book_logo_big,book_logo_small,book_name,book_price,book_price_old," +
                "book_author,book_press,book_description,store_count,type_id,`status`,is_new,is_hot)\n" +
                "values (?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] obj = {bookInfo.getBook_logo_big(),bookInfo.getBook_logo_small(),bookInfo.getBook_name(),
                bookInfo.getBook_price(),bookInfo.getBook_price_old(),bookInfo.getBook_author(),
                bookInfo.getBook_press(),bookInfo.getBook_description(),bookInfo.getStore_count(),
                bookInfo.getType_id(),bookInfo.getStatus(),bookInfo.getIs_new(),bookInfo.getIs_hot()
        };

        return new ORMUtil().executeDMLByInsert(sql,obj);
    }

    @Override
    public int insertBookPic(BookPicInfo bookPicInfo) {
        return 0;
    }

    @Override
    public List<BookInfo> selectBook() {
        return null;
    }
}
